<?php
class Admin_Profile_EditInputView extends BlogAdminBaseView
{
    public function executeHtml(AgaviRequestDataHolder $rd)
    {
        $this->setupHtml($rd, 'blog');
        $ro = $this->getContext()->getRouting();
        /* @var $user User */
        $user = $this->getAttribute('user');

        /* @var $role UserRole */
        $trusted_user_role = null;
        foreach ($user->Roles as $role) {
            if ($role->role_name === 'trusted-user') {
                $trusted_user_role = $role;
                break;
            }
        }

        $form_params = array(
            'display_name' => $user->display_name,
            'email' => $user->email,
            'website' => $user->website
            );
            
        if ($trusted_user_role instanceof UserRole) {
            $form_params['trusted'] = 1;
        }
        $this->getContext()->getRequest()->setAttribute('populate', new AgaviParameterHolder($form_params), 'org.agavi.filter.FormPopulationFilter');
        
        $this->setAttribute('title', 'Edit profile');
        $this->setAttribute('user_type', $user->user_type);
        $this->setAttribute('submit_route', $ro->gen('profile.edit', array('user_id' => $user->id)));
        $this->setAttribute('login_name', $user->login_name);
    }
}
?>
